<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="utf-8">

    <style>

        .title {
            text-align: center;
            margin-bottom: 15px;
        }

        #price_from {
            width: 30%;
            display: inline;
            text-align: center;
            border: 0;
        }

        #price_to {
            width: 30%;
            text-align: center;
            border: 0;

        }

        #price_panel button {
            margin-top: 10px;
            width: 120px;
            height: 30px;
            background: #287CD4;
            color: #fff;
            border: 0;
            -moz-border-radius: 5px;
            -webkit-border-radius: 5px;
            border-radius: 5px;
        }

    </style>
</head>
<body>

<div>
    <div id="price_panel">

        <h4 class="title">
            价格
        </h4>


        <!--按照价格区间-->
        <div style="margin-bottom: 10px">
            <input placeholder="最低" id="price_from" type="number">
            <b style="width: 5%">-</b>
            <input placeholder="最高" id="price_to" type="number">
        </div>

        <select id="price_unit" style="width: 46%;padding-left: 20%;border: 0;">
            <option value="-1">租用单位</option>
            <option value="10">小时</option>
            <option value="5">日租</option>
            <option value="2">月租</option>
            <option value="1">年租</option>
        </select>

        <select id="price_sort" style="width: 46%;padding-left: 20%;border: 0;margin-top: 5px">
            <option value="升">由低到高</option>
            <option value="降">由高到底</option>
        </select>

        <button id="condition_ok_bt">确定</button>

    </div>
</div>

<script>


    $('#condition_ok_bt').click(function () {

        //收集参数

        let price_from = Number($('#price_from').val());

        let price_to = Number($('#price_to').val());

        let price_sort = $('#price_sort').val();

        let price_unit = Number($('#price_unit').val());


        if (price_to === 0) {
            price_to = 999999;
        }

        let map = {
            price_from: price_from,
            price_to: price_to,
            price_sort: price_sort,
            price_unit: price_unit
        };

        if (price_from < 0 || price_from > price_to) {
            alert('无效的价格区间');
        } else {
            close_dialog();
            Event.fanout('condition_panel_ok', map);
        }
    });

</script>

</body>
</html>